package com.leetcode.根据数据结构分类.数组;

/**
 * @author: xiaomi
 * @date: 2021/2/15
 * @description: 485. 最大连续1的个数
 * https://leetcode-cn.com/problems/max-consecutive-ones/
 */
public class A_485_最大连续1的个数 {

    public static void main(String[] args) {

    }

    public int findMaxConsecutiveOnes(int[] nums) {
        int res = 0;
        boolean flag = false;
        int len = nums.length;
        int temp = 0;
        for (int i = 0; i < len; i++) {
            if (nums[i] == 1) {
                temp++;
            } else {
                res = Math.max(res, temp);
                temp = 0;
            }
        }
        res = Math.max(res, temp);
        return res;
    }
}
